package com.party.core.dao.read.crowdfund;

import com.party.common.paging.Page;
import com.party.core.dao.read.BaseReadDao;
import com.party.core.model.crowdfund.EventGradation;
import com.party.core.model.crowdfund.Project;
import com.party.core.model.crowdfund.ProjectGradation;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author: huangzequn
 * @Date: 2019/3/20 10:49
 */
@Repository
public interface ProjectGradationReadDao extends BaseReadDao<ProjectGradation> {


    /***
     * 多场活动个人排行榜，财富，人气
     * @param page
     * @return
     */
    List<ProjectGradation> speedList(@Param("params") Map<String, String> params, Page page);

    /***
     * 个人排行榜  自己的个人信息
     * @param
     * @return
     */
    ProjectGradation popularity(@Param("params")Map<String, String> params, @Param("type")String type);


    /***
     * 查询该项目下的所有报名人员
     * @param targetId
     * @param page
     * @return
     */
    List<Project> getProjectByActivityId(String targetId, Page page);

    /***
     * 查询该主题下的所有报名人员
     * @param eventId
     * @param page
     * @return
     */
    List<Project> queryProjectByTargetId(String eventId, Page page);

    /**
     * * 找出所有报名者已消费的总金额，比如说当前系统时间是第三阶段，则需要找出第一第二阶段的目标金额
     *  并且加条件过滤出来   第一第二阶段标记已参赛的  或者 有阶段筹满时间的
     * @param params
     * @return
     */
    List<ProjectGradation> getProjectGradationByTargetId(@Param("params") Map<String, Object> params);

    List<Map<String,Object>> listForProjectId(@Param(value = "projectId") String projectId);

    /**
     * @param endTime   截止时间
     * @param projectId 众筹id
     * @return java.lang.Double
     * @Author yifeng
     * @Description 获取众筹的阶段前有效的累计金额
     * @Date 9:41 2019/3/25
     **/
    Double getEffectiveAmount(@Param(value = "endTime") Date endTime, @Param(value = "projectId") String projectId);

    /***
     * 根据eventGradationId找到ProjectGradation
     * @param eventGradationId
     * @return
     */
    ProjectGradation getByEventGradationId(@Param("eventGradationId") String eventGradationId,@Param("projectId")String projectId);

    /**
     * @param eventId 主题id
     * @return
     * @Author yifeng
     * @Description 已消费的金额
     * @Date 16:21 2019/3/25
     **/
    Double getConsumedAmount(@Param(value = "eventId") String eventId);

    /**
     * @param projectId 众筹id
     * @return
     * @Author yifeng
     * @Description 获取成功的众筹阶段
     * @Date 11:29 2019/3/28
     **/
    List<ProjectGradation> getSuccessListForProjectId(@Param(value = "projectId") String projectId);

    List<ProjectGradation> findByProjectId(@Param(value = "projectId") String projectId);

    /**
     * @param projectId 众筹id
     * @return
     * @Author yifeng
     * @Description 获取众筹的有效阶段数
     * @Date 15:29 2019/4/8
     **/
    Integer getEffectiveCount(String projectId);

    /**
    * @Author hzq
    * @Description //获取当前众筹者正在众筹阶段的后面所有阶段
    * @Date 15:32 2019/4/18
    * @param ongoingGradation
    * @return
    **/
    List<ProjectGradation> getAfterProjectGradations(@Param("ongoingGradation") EventGradation ongoingGradation,
                                                     @Param("projectId") String projectId);

    /**
    * @Author hzq
    * @Description //根据当前阶段找到上一阶段
    * @Date 15:50 2019/4/18
    * @param ongoingProjectGradation
    * @return
    **/
    ProjectGradation getTheNextGradation(@Param("ongoingProjectGradation") ProjectGradation ongoingProjectGradation);
}
